<template>
  <div class="user-list">
    <div class="content-head" style="margin-bottom: 20px;">
      <div class="sort-keys">

        <div class="tab-list">
           <div class="item" @click="keys.type = item.key" :class="{actived: keys.type === item.key}"
             v-for="(item, index) in statusList">
             {{item.text}}
             ({{statusTotal[item.key]}})
           </div>
         </div>

        <!-- <a-radio-group v-model="sort" buttonStyle="solid" style="margin-right:10px;">
          <a-radio-button value="time">注册时间</a-radio-button>
          <a-radio-button value="score">幸运值</a-radio-button>
          <a-radio-button value="repack">红包</a-radio-button>
          <a-radio-button value="invitee">邀请数</a-radio-button>
        </a-radio-group> -->

      </div>
      <div class="sort-keys">
        <a-input
          placeholder="输入关键字"
          style="width: 180px;margin-right:10px;"
          v-model="key"
          allowClear
          @input="onSearch"
        />
        <a-input
          placeholder="输入用户ID"
          style="width: 180px;margin-right:10px;"
          v-model="find_user_id"
          allowClear
          @input="onSearch"
        />
        <span style="margin-left: 20px; margin-right: 6px;">广告ID:</span>
        <a-input
          placeholder="输入广告ID"
          style="width: 180px;margin-right:10px;"
          v-model="aid"
          allowClear
          @input="onSearch"
        />
        <span style="margin-left: 20px; margin-right: 6px;">注册日期:</span>
        <iDatePicker :showTime="false" style="margin-left: 10px;" placeholder="不选则不限制" v-model="filter.min_day"></iDatePicker>
        至
        <iDatePicker :showTime="false" style="margin-left: 0px;" placeholder="不选则不限制" v-model="filter.max_day"></iDatePicker>
        <a-button type="primary" @click="refresh" style="margin-right:10px;">刷新</a-button>
      </div>

      <div style="margin-top: 4px;" v-if="action_show  && is_super">
        <a-button type="primary" style="margin-right:10px;"  @click="isExport = !isExport">导出Excel</a-button>
        <a-button v-if="keys.type=='adq'" style="margin-left: 30px; float: right;" type="primary" @click="isExport2 = !isExport2">
          <span>营收查询</span>
        </a-button>
      </div>
    </div>
    <span>
          {{adq_text}}
        </span>
    <a-table
      class="table"
      :rowKey="row => row.uuid"
      :dataSource="list"
      :pagination="pagination"
      @change="onPaginationChange"
    >
      <a-table-column
        title="姓名"
        key="name"
        width="230px"
      >
        <template slot-scope="row">
          <div class="user">
            <img class="headimg" :src="row.headimg" alt="用户头像">

            <div class='right'>
              <div class="top">
                <span>{{ row.name }}</span>
                <a-icon class="gender-man" v-if="row.gender==='男'" type="man" />
                <a-icon class="gender-woman" v-else-if="row.gender==='女'" type="woman" />
                <!-- <a-tag color="red" style="margin-left: 10px;" v-if="row.client_type === 'ali'">天猫用户</a-tag> -->
                <a href="javascript:;" style="margin-left: 10px;" v-if="action_show && is_super" @click="handleEdit(row)">编辑</a>
                <a href="javascript:;" style="margin-left: 10px;" v-else-if="action_show && best_yunyin_show" @click="handleEdit3(row)">编辑</a>
                <a href="javascript:;" style="margin-left: 10px;" v-else-if="action_show" @click="handleEdit2(row)">编辑</a>

                <!-- <a-tag color="red" v-if="row.status === 2">已拉黑</a-tag> -->
              </div>
              <div class="bottom" style="margin-top: 4px;">

                <span class="marked-tag" @click="markItem(row)" :class="{actived: row.marked_at}">标记</span>

                <!-- <span>{{row.city}}</span> -->
                <span>{{row.phone}}</span>
                </br><span>ID:{{row.id}}</span>

                <a-tag color="red" style="margin-left:10px;" v-if="row.status === 2">已拉黑</a-tag>
                <a-tag color="red" style="margin-left:10px;" v-if="row.is_nopay === 1">禁付</a-tag>
                <a-tag color="red" style="margin-left:10px;" v-if="row.is_nogs === 1">禁售</a-tag>

                <div v-if="action_show">
                <a-tag color="red" style="margin-left:10px;" v-if="row.is_rb === 1">马甲</a-tag>
                <a-tag color="red" style="margin-left:10px;" v-if="row.is_rb2 === 1">主播</a-tag>
                <a-tag color="red" style="margin-left:10px;" v-if="row.is_liu === 1">老六</a-tag>
                </div>
              </div>
              <span v-if="action_show">{{ row.remark }}</span>
            </div>
          </div>
        </template>
      </a-table-column>
      
      <a-table-column
        title="邀请关系"
        width="160px"
      >
        <template slot-scope="row">
          <div>
            <div>
              上级:
              <template v-if="row.inviter">
                <img class="inviter-headimg" :src="row.inviter.headimg" alt="用户头像">
                {{row.inviter.name}}
              </template>
              <template v-else>-</template>
            </div>
            <div>直接粉丝: {{row.direct_invitees_count}}人</div>
            <div>间接粉丝: {{row.indirect_invitees_count}}人</div>
            <div v-if="row.aid_text">广告ID: {{row.aid_text}}</div>
          </div>
        </template>
      </a-table-column>
      <a-table-column title="微信群" width="80px" v-if="action_show">
        <template slot-scope="row">
          <a-tag style="margin-left:10px;" v-for="(item, index) in row.qy_groups">{{item}}</a-tag>
        </template>
      </a-table-column>
      <a-table-column title="IP记录" width="80px" v-if="action_show">
        <template slot-scope="row">
          <a href="javascript:;" @click="handleIpLog(row.id)">IP记录</a>
        </template>
      </a-table-column>

      <a-table-column title="明细" width="80px" v-if="action_show">
        <template slot-scope="row">
          <a href="javascript:;" @click="handleMxLog(row.id)">明细</a>
        </template>
      </a-table-column>

      <a-table-column title="成长等级" width="80px" v-if="action_show">
        <template slot-scope="row">
          <a href="javascript:;" @click="handleAddLevelScore(row)" v-if="is_super || best_yunyin_show">{{row.task_level}}级</a>
          <div v-else>{{row.task_level}}级</div>
        </template>
      </a-table-column>
      <a-table-column title="双倍卡" width="80px" v-if="action_show">
        <template slot-scope="row">
          <a href="javascript:;" @click="handleDoubleLog(row.id)">{{row.double_box}}</a>
        </template>
      </a-table-column>
      <!-- <a-table-column
        title="邀请数"
        width="70px"
      >
        <template slot-scope="row">
          <div>{{row.invitees_count}}人</div>
        </template>
      </a-table-column> -->
      <a-table-column
        title="首单购买时间"
        key="sd_created_at"
        width="110px"
      >
        <template slot-scope="row">
          <span>{{ row.sd_created_at | formatDate2}}</span>
        </template>
      </a-table-column>
      <a-table-column
        title="实付总金额"
        key="paidtotal"
        width="180px"
        v-if="action_show"
      >
        <template slot-scope="row">
          <div>总:{{row.paidtotal / 100}}元</div>
          <div>抽/充:{{row.paidtotal2 / 100}}元</div>
          <div>转/提:{{row.paidtotal3 / 100}}元</div>
          <div>库退:{{row.paidtotal4 / 100}}元</div>
        </template>
      </a-table-column>

       <a-table-column
        title="提现中"
        width="110px"
        v-if="action_show"
      >
        <template slot-scope="row">
          <div>{{row.withdraw_pending / 100}}元</div>
        </template>
      </a-table-column>

       <a-table-column
        title="已提现"
        width="110px"
        v-if="action_show"
      >
        <template slot-scope="row">
          <div>{{row.withdraw_completed / 100}}元</div>
        </template>
      </a-table-column>

      <a-table-column
        title="已提货"
        width="110px"
        v-if="action_show"
      >
        <template slot-scope="row">
          <div>{{row.picked / 100}}元</div>
        </template>
      </a-table-column>
      
      <a-table-column
        title="积分"
        key="score"
        width="80px"
      >
        <template slot-scope="row">
          <div>{{row.score}}积分</div>
        </template>
      </a-table-column>
      <a-table-column
        title="红包"
        key="redpack"
        width="80px"
      >
        <template slot-scope="row">
          <div>{{row.redpack / 100}}元</div>
        </template>
      </a-table-column>
      <a-table-column
        title="福袋欧气值"
        key="lucky_score"
        width="120px"
      >
        <template slot-scope="row">
          <div>
            {{row.lucky_score}}
            <a href="javascript:;" style="margin-left: 6px;" v-if="action_show && (is_super  || best_yunyin_show)" @click="handleEditFudaiLuckyScore(row)">修改</a>
          </div>
        </template>
      </a-table-column>
      <a-table-column
        title="注册日期"
        dataIndex="created_at"
        key="created_at"
        width="110px"
      >
        <template slot-scope="created_at">
          <span>{{ created_at | formatDate2 }}</span>
        </template>
      </a-table-column>
      <a-table-column
        title="最后活跃"
        dataIndex="last_active_at"
        key="last_active_at"
        width="100px"
      >
        <template slot-scope="last_active_at">
          <span>{{ last_active_at | formatDate }}</span>
        </template>
      </a-table-column>
      <a-table-column
        title="操作"
        key="action"
        width="200px"
        v-if="action_show"
      >
        <template slot-scope="row">
          <span>
           <div v-if="is_super">
             <a href="javascript:;" @click="handleAddScore(row)">修改积分</a>
             <a-divider type="vertical" />
             <a href="javascript:;" @click="handleAddRedpack(row)">修改红包</a>
           </div>
           <div style="margin-top: 6px;">
             <a href="javascript:;" @click="handleGetPath(row)" v-if="1==2">分销链接</a>
             <div v-if="is_super || best_yunyin_show">
             <a href="javascript:;" @click="handleBlockUser(row)" v-if="row.status !== 2">拉黑</a>
             <a href="javascript:;" @click="handleUnblockUser(row)" v-else>取消拉黑</a>
             <a-divider type="vertical" />
             <a href="javascript:;" @click="handleBlockUser2(row)" v-if="row.is_nopay !== 1">禁付</a>
             <a href="javascript:;" @click="handleUnblockUser2(row)" v-else>取消禁付</a>
             <a-divider type="vertical" />
             <a href="javascript:;" @click="handleBlockUser3(row)" v-if="row.is_nogs !== 1">禁售</a>
             <a href="javascript:;" @click="handleUnblockUser3(row)" v-else>取消禁售</a>
             </div>
           </div>

          </span>
        </template>
      </a-table-column>
    </a-table>

    <ExportPopup @hide="isExport=false" :isShow="isExport"></ExportPopup>
    <ExportPopup2 @hide="isExport2=false" :isShow="isExport2"></ExportPopup2>
    <a-modal title="Ip记录" style="top: 100px;" :visible="isIpLog" width="1200px" @cancel="isIpLog = false" :footer="null">
      <Iplog v-if="isIpLog" :user_id="user_id" @cancel="isIpLog = false" @success="fetchData"></Iplog>
    </a-modal>
    <a-modal title="用户明细(默认显示30天内的)" style="top: 100px;" :visible="isMxLog" width="1200px" @cancel="isMxLog = false" :footer="null">
      <Mxlog v-if="isMxLog" :user_id="user_id" @cancel="isMxLog = false" @success="fetchData"></Mxlog>
    </a-modal>
    <a-modal title="双倍卡记录" style="top: 100px;" :visible="isDoubleLog" width="1200px" @cancel="isDoubleLog = false" :footer="null">
      <DoubleLog v-if="isDoubleLog" :user_id="user_id" @cancel="isDoubleLog = false" @success="fetchData"></DoubleLog>
    </a-modal>
  </div>

</template>
<script>
import { getUserList, updateUser } from '@/api/users'
import moment from 'moment'
import ExportPopup from "./components/ExportPopup"
import ExportPopup2 from "./components/ExportPopup2"
import Iplog from "./components/Iplog.vue"
import Mxlog from "./components/Mxlog.vue"
import DoubleLog from "./components/DoubleLog.vue"
import IDatePicker from "@/components/IDatePicker/IDatePicker.vue"

export default {
  name: 'UserList',
  components: {
    ExportPopup,
    ExportPopup2,
    Iplog,
    Mxlog,
    DoubleLog,
    IDatePicker,
  },
  data () {
    return {
      action_show : false,
      best_yunyin_show : false,
      is_super : false,
      isIpLog: false,
      isMxLog: false,
      isDoubleLog: false,
      user_id: 0,
      statusList: [
        {
          text: '微信',
          key: 'wechat'
        },
        {
          text: '支付宝',
          key: 'alipay'
        },
        {
          text: 'APP',
          key: 'app'
        },
        {
          text: '微信广告',
          key: 'adq'
        },
        {
          text: '抖音广告',
          key: 'dy'
        },
        {
          text: '标记的',
          key: 'marked'
        },
        {
          text: '马甲',
          key: 'majia'
        },
        {
          text: '主播',
          key: 'zhubo'
        },
        {
          text: '老六',
          key: 'laoliu'
        },
        {
          text: '禁止支付',
          key: 'nopay'
        },
        {
          text: '禁止挂售',
          key: 'nogs'
        },
        {
          text: '拉黑的',
          key: 'blocked'
        }
      ],
      statusList2: [
        {
          text: '微信',
          key: 'wechat'
        },
        {
          text: '支付宝',
          key: 'alipay'
        },
        {
          text: '微信广告',
          key: 'adq'
        },
        {
          text: '抖音广告',
          key: 'dy'
        },
        {
          text: '禁止支付',
          key: 'nopay'
        },
        {
          text: '拉黑的',
          key: 'blocked'
        }
      ],
      // actived: 'wechat',
      keys: {
        type: 'wechat'
      },
      statusTotal: {
        wechat: 0,
        byte_dance: 0,
        marked: 0,
        blocked: 0,
        alipay: 0,
        web: 0
      },
      loading: false,
      list: [],
      page: 1,
      per_page: 10,
      total: 0,
      key: '',
      find_user_id:'',
      aid: '',
      sort: 'time',
      form: this.$form.createForm(this),
      visible: false,
      confirmLoading: false,
      timeout: null,
      isExport: false,
      isExport2: false,
      adq_text: '',
      filter: {
        min_day: '',
        max_day: ''
      }
    }
  },
  computed: {
    pagination () {
      return {
        defaultPageSize: this.per_page,
        defaultCurrent: this.page,
        total: this.total,
        showTotal: total => `共 ${total} 条`
      }
    }
  },
  filters: {
    formatDate (value) {
      return value ? moment(value).fromNow() : ''
    },
    formatDate2 (value) {
      return value ? moment(value).format('YYYY-MM-DD HH:mm') : ''
    },
 
  },
  created () {
    this.action_show = this.$authCheck('Users_lb')
    this.best_yunyin_show = this.$authCheck('best_yunyin')
    if(!this.action_show){
      this.statusList = this.statusList2
    }
    if(Vue.ls.get('is_super')){
      this.is_super = true;
    }else{
      this.is_super = false;
    }

    this.fetchData()
    this.fetchTotalData()
  },
  watch: {
    sort(val) {
      this.fetchData()
    },
    keys: {
      handler(value) {
        this.refresh()
      },
      deep: true
    },
    'filter.min_day'() {
      this.refresh()
    },
    'filter.max_day'() {
      this.refresh()
    }
  },
  methods: {
    handleIpLog(user_id){
      this.isIpLog = true;
      this.user_id = user_id;
    },
    handleMxLog(user_id){
      this.isMxLog = true;
      this.user_id = user_id;
    },
    handleDoubleLog(user_id){
      this.isDoubleLog = true;
      this.user_id = user_id;
    },
    handleGetPath(row) {
      this.$getPathPopup.show({
        page: '/pages/index/index',
        param: 'inviter=' + row.uuid
      });
    },
    handleBlockUser(row) {
      this.$confirm({
        title: '确认要拉黑用户吗',
        content: `拉黑后用户能正常浏览页面，但不能进行需要登录的操作，如下单、加购物车，同时不结算佣金。`,
        onOk: () => {
          this.$http.patch(`/users/${row.uuid}`, {
            type: 'block'
          }).then(res => {
            this.fetchData()
            this.fetchTotalData()
          })
        }
      })
    },
    handleBlockUser2(row) {
      this.$confirm({
        title: '确认要禁付用户吗',
        content: `禁付后用户将被禁止支付和领取宝箱等~`,
        onOk: () => {
          this.$http.patch(`/users/${row.uuid}`, {
            type: 'nopay'
          }).then(res => {
            this.fetchData()
            this.fetchTotalData()
          })
        }
      })
    },
    handleBlockUser3(row) {
      this.$confirm({
        title: '确认要禁售用户吗',
        content: `禁售后用户被禁止转售商品`,
        onOk: () => {
          this.$http.patch(`/users/${row.uuid}`, {
            type: 'nogs'
          }).then(res => {
            this.fetchData()
            this.fetchTotalData()
          })
        }
      })
    },
    handleUnblockUser(row) {
      this.$confirm({
        title: '提示',
        content: `确认要取消拉黑用户吗？`,
        onOk: () => {
          this.$http.patch(`/users/${row.uuid}`, {
            type: 'unblock'
          }).then(res => {
            this.fetchData()
            this.fetchTotalData()
          })
        }
      })
    },
    handleUnblockUser2(row) {
      this.$confirm({
        title: '提示',
        content: `确认要取消禁付用户吗？`,
        onOk: () => {
          this.$http.patch(`/users/${row.uuid}`, {
            type: 'unnopay'
          }).then(res => {
            this.fetchData()
            this.fetchTotalData()
          })
        }
      })
    },
    handleUnblockUser3(row) {
      this.$confirm({
        title: '提示',
        content: `确认要取消禁售用户吗？`,
        onOk: () => {
          this.$http.patch(`/users/${row.uuid}`, {
            type: 'unnogs'
          }).then(res => {
            this.fetchData()
            this.fetchTotalData()
          })
        }
      })
    },
    // 标记
    markItem(row) {
       this.$http.patch(`/users/${row.uuid}`, {
         type: 'mark'
       }).then((res) => {
         this.$message.success('保存成功')
         this.fetchData()
         this.fetchTotalData()
       })
    },
    onPaginationChange (e) {
      this.page = e.current
      this.per_page = e.pageSize
      this.fetchData()
    },
    refresh () {
      this.page = 1
      this.fetchData()
      this.fetchTotalData()
    },
    onSearch (e) {
      this.page = 1
      clearTimeout(this.timeout)
      this.timeout = setTimeout(() => {
        this.fetchData()
      }, 300)
    },
    handleEditFudaiLuckyScore (row) {
      this.$iForm.show({
        title: '修改福袋欧气值',
        frame: [
          {
            type: 'text',
            title: '当前值',
            text: row.lucky_score
          },
          {
            type: 'number',
            key: 'value',
            title: '新的数值',
            default: row.lucky_score,
            required: true
          }
        ],
        success: (data) => {
          this.$http({
            url: `/users/${row.uuid}`,
            method: 'PATCH',
            data: {
              type: 'update_fudai_lucky_score',
              ...data
            }
          }).then(res => {
            this.$message.success('操作成功');
            this.$iForm.hide()
            this.fetchData()
          })
        }
      })
    },
    handleAddScore (row) {
      this.$iForm.show({
        title: '修改用户积分',
        frame: [
          {
            type: 'radio',
            key: 'type',
            options: [
              {
                title: '增加',
                value: 'in'
              },
              {
                title: '减少',
                value: 'out'
              }
            ],
            title: '变动类型',
            required: true
          },
          {
            type: 'number',
            key: 'score',
            title: '变动数量',
            required: true
          },
          {
            type: 'textarea',
            key: 'description',
            title: '变动原因',
            tips: '变动原因会显示在用户的积分流水记录中',
            required: true
          },
        ],
        success: (data) => {
          this.$http({
            url: `/users/${row.uuid}/score`,
            method: 'PATCH',
            data: {
              type: 'add',
              ...data
            }
          }).then(res => {
            this.$message.success('操作成功');
            this.$iForm.hide()
            this.fetchData()
          })
        }
      })
    },
    handleAddLevelScore (row) {
      this.$iForm.show({
        title: '修改用户成长值',
        frame: [
          {
            type: 'radio',
            key: 'type',
            options: [
              {
                title: '增加',
                value: 'in'
              },
              {
                title: '减少',
                value: 'out'
              }
            ],
            title: '变动类型',
            required: true
          },
          {
            type: 'number',
            key: 'level_score',
            title: '变动数量',
            required: true
          },
          {
            type: 'textarea',
            key: 'description',
            title: '变动原因',
            tips: '变动原因会显示在用户的积分流水记录中',
            required: true
          },
        ],
        success: (data) => {
          this.$http({
            url: `/users/${row.uuid}/level_score`,
            method: 'PATCH',
            data: {
              type: 'add',
              ...data
            }
          }).then(res => {
            this.$message.success('操作成功');
            this.$iForm.hide()
            this.fetchData()
          })
        }
      })
    },
    handleAddRedpack (row) {
      this.$iForm.show({
        title: '修改用户红包',
        frame: [
          {
            type: 'radio',
            key: 'type',
            options: [
              {
                title: '增加',
                value: 'in'
              },
              {
                title: '减少',
                value: 'out'
              }
            ],
            title: '变动类型',
            required: true
          },
          {
            type: 'price',
            key: 'redpack',
            title: '变动金额',
            required: true
          },
          {
            type: 'textarea',
            key: 'description',
            title: '变动原因',
            tips: '变动原因会显示在用户的红包流水记录中',
            required: true
          },
        ],
        success: (data) => {
          this.$http({
            url: `/users/${row.uuid}/redpack`,
            method: 'PATCH',
            data: {
              type: 'add',
              ...data
            }
          }).then(res => {
            this.$message.success('操作成功');
            this.$iForm.hide()
            this.fetchData()
          })
        }
      })
    },
    handleEdit (row) {
      this.$iForm.show({
        title: '修改用户信息',
        frame: [
          {
            type: 'input',
            key: 'name',
            title: '用户名',
            default: row.name,
            required: true
          },
          {
            type: 'input',
            key: 'phone',
            title: '手机号',
            default: row.phone
          },
          {
            type: 'input',
            key: 'city',
            title: '地区',
            default: row.city
          },
          {
            type: 'textarea',
            key: 'remark',
            title: '备注',
            default: row.remark
          },
          {
            type: 'yzm',
            key: 'yzm',
            title: '验证码',
            tips: '如果需要更改马甲状态则需要验证码,如果不是就忽略'
          },
          {
            title: '马甲',
            key: 'is_rb',
            type: 'radio',
            default: row.is_rb,
            required: true,
            span: 24,
            options: [{
                title: '否',
                value: 0
              },
              {
                title: '是',
                value: 1
              }
            ],
            tips: '购买无限赏不计销量'
          },
          {
            title: '主播',
            key: 'is_rb2',
            type: 'radio',
            default: row.is_rb2,
            required: true,
            span: 24,
            options: [{
                title: '否',
                value: 0
              },
              {
                title: '是',
                value: 1
              }
            ],
            tips: '购买无限赏不计销量'
          },
          {
            title: '老六',
            key: 'is_liu',
            type: 'radio',
            default: row.is_liu,
            required: true,
            span: 24,
            options: [{
                title: '否',
                value: 0
              },
              {
                title: '是',
                value: 1
              }
            ],
            tips: '老六优先级高于马甲!请不要同时选择'
          },
        ],
        success: (data) => {
          this.$http({
            url: `/users/${row.uuid}`,
            method: 'PATCH',
            data: {
              type: 'update',
              attributes: data
            }
          }).then(res => {
            this.$message.success('更新成功');
            this.$iForm.hide()
            this.fetchData()
          })
        }
      })
    },
    handleEdit2 (row) {
      this.$iForm.show({
        title: '修改用户信息',
        frame: [
          {
            type: 'textarea',
            key: 'remark',
            title: '备注',
            default: row.remark
          },
          {
            title: '老六',
            key: 'is_liu',
            type: 'radio',
            default: row.is_liu,
            required: true,
            span: 24,
            options: [{
                title: '否',
                value: 0
              },
              {
                title: '是',
                value: 1
              }
            ],
            tips: '老六优先级高于马甲!请不要同时选择'
          },
        ],
        success: (data) => {
          this.$http({
            url: `/users/${row.uuid}`,
            method: 'PATCH',
            data: {
              type: 'update',
              attributes: data
            }
          }).then(res => {
            this.$message.success('更新成功');
            this.$iForm.hide()
            this.fetchData()
          })
        }
      })
    },
    handleEdit3 (row) {
      this.$iForm.show({
        title: '修改用户信息',
        frame: [
          {
            type: 'textarea',
            key: 'remark',
            title: '备注',
            default: row.remark
          },
          {
            title: '老六',
            key: 'is_liu',
            type: 'radio',
            default: row.is_liu,
            required: true,
            span: 24,
            options: [{
                title: '否',
                value: 0
              },
              {
                title: '是',
                value: 1
              }
            ],
            tips: '老六优先级高于马甲!请不要同时选择'
          },
        ],
        success: (data) => {
          this.$http({
            url: `/users/${row.uuid}`,
            method: 'PATCH',
            data: {
              type: 'update',
              attributes: data
            }
          }).then(res => {
            this.$message.success('更新成功');
            this.$iForm.hide()
            this.fetchData()
          })
        }
      })
    },
    handleOk () {
      this.form.validateFields((err, values) => {
        if (!err) {
          this.confirmLoading = true
          updateUser(values, this.current.uuid).then(res => {
            this.visible = false
            this.fetchData()
          }).finally(() => {
            this.confirmLoading = false
          })
        }
      })
    },
    fetchTotalData() {
      this.$http('/status-total/user').then((res) => {
        this.statusTotal = res.data.total
      })
    },
    fetchAdqTotalData() {
      this.adq_text =  '营收统计获取中~~~'
      this.$http('/adq-total/user').then((res) => {
        this.adq_text = 
        '昨日营收:' + res.data.a1/100 + ',昨日新用户营收:' + res.data.d1/100 +
        ';   今日营收:' + res.data.a0/100 + ',今日新用户营收:' + res.data.d0/100 +
        ';   7日内营收:' + res.data.a3/100 + ',7日内新用户营收:' + res.data.d3/100 +
        ';   30日内营收:' + res.data.a4/100 + ',30内新用户营收:' + res.data.d4/100 +
        ';   本月营收:' + res.data.a5/100 + ',本月新用户营收:' + res.data.d5/100;
      })
    },
    fetchData () {
      if(this.keys.type == 'adq' && this.page == 1){
        this.fetchAdqTotalData();
      }else if(this.keys.type != 'adq'){
        this.adq_text = '';
      }
      this.loading = true
      getUserList({
        page: this.page,
        per_page: this.per_page,
        key: this.key,
        find_user_id: this.find_user_id,
        aid: this.aid,
        sort: this.sort,
        type: this.keys.type,
        created_start_at: this.filter.min_day,
        created_end_at: this.filter.max_day,
      }).then(res => {
        this.list = res.data.list
        this.total = res.data.item_total
        console.log(this.list)
      }).finally(() => {
        this.loading = false
      })
    },
  }
}
</script>
<style lang="less" scoped>

  .marked-tag {
    border-radius: 50px;
    border: 1px solid #666;
    font-size: 10px;
    padding: 1px 6px;
    color: #666;
    cursor: pointer;
    margin-right: 6px;

    &.actived {
      background: #666;
      color: white;
    }
  }


  .sort-keys {
    display: flex;
    align-items: center;

    .tab-list {
      display: flex;
      margin-top: 6px;
      border-bottom: 1px solid #e1e1e1;
      margin-right: 50px;

      .item {
        margin-right: 30px;
        padding: 0px 10px 4px 10px;
        cursor: pointer;
        font-weight: 500;

        &.actived {
          color: #1890FF;
          border-bottom: 3px solid #1890FF;
        }

        &:hover {
          color: #1890FF;
        }
      }
    }

  }

.inviter-headimg {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.content-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
.table {
  background-color: #fff;
  .user {
    display: flex;
    // flex-wrap: wrap;
    align-items: center;
    img {
      width: 38px;
      height: 38px;
      flex: 0 0 38px;
      border: 1px solid #e1e1e1;
      margin-right: 6px;
      border-radius: 50%;
      overflow: hidden;
    }
    .gender-man, .gender-woman {
      margin-left: 5px;
      font-size: 12px;
    }
    .gender-man {
      color: #409EFF;
    }
    .gender-woman {
      color: #F56C6C;
    }
  }
}
</style>
